import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      redirect: 'login'
    },
    {
      path: '/register',
      name: 'register',
      component: ()=> import('@/pages/register.vue')
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/pages/login.vue')
    },
    {
      path: '/student',
      name:'student',
      redirect: '/student/index',
      component: () => import('@/pages/user/index.vue'),
      children:[
        {
          path:'index',
          name: 'index',
          component: () => import('@/pages/user/modalvisi')
        }
      ]
    }
  ]
})
// 路由监控跳转页面
// router.beforeEach((to, from, next) => {
//   console.log(this, 'yikaishi')
//   let _this = Vue.prototype
//   let userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
//   if (userInfo && userInfo.token_assess) {
//     next()
//   } else if (to.path === '/login') {
//     console.log(111)
//     next()
//   } else {
//     console.log(111, this)
//     _this.$message({
//       message: '请登录',
//       type: 'error',
//       center: true,
//       onClose () {
//         // console.log(111)
//         next('/login')
//       }
//     })
//   }
// })
